<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="所属公司">
        <TenantChoose @loaded="search" v-model="form.tenant_id" />
      </el-form-item>
      <br />

      <el-form-item label="所属站点">
        <SiteRadioAll v-model="form.site_id" @change="search" />
      </el-form-item>

      <br />
      <el-form-item label="代理">
        <el-radio-group v-model="form.sons" @change="search">
          <el-radio-button :label="0">全部</el-radio-button>
          <el-radio-button :label="1">代理</el-radio-button>
          <el-radio-button :label="2">普通会员</el-radio-button>
        </el-radio-group>
        <br />
      </el-form-item>

      <br />
      <el-form-item label="黑名单">
        <el-radio-group v-model="form.blacklist" @change="search">
          <el-radio-button :label="99999999">全部</el-radio-button>
          <el-radio-button :label="0">正常</el-radio-button>
          <el-radio-button :label="1">黑名单</el-radio-button>
        </el-radio-group>
      </el-form-item>

      <br />
      <el-form-item label="激活">
        <el-radio-group v-model="form.active" @change="search">
          <el-radio-button :label="1">正常</el-radio-button>
          <el-radio-button :label="0">未激活</el-radio-button>
        </el-radio-group>
      </el-form-item>

      <br />
      <el-form-item label="会员名字">
        <el-input clearable v-model.trim="form.realname" />
      </el-form-item>

      <el-form-item label="联系电话">
        <el-input clearable v-model.trim="form.tel" />
      </el-form-item>

      <el-form-item label="所在学校">
        <el-input clearable v-model.trim="form.school" />
      </el-form-item>

      <el-form-item label="身份证号">
        <el-input clearable v-model.trim="form.identifier" />
      </el-form-item>

      <el-form-item label="工作次数">
        <el-input
          clearable
          v-model.trim="form.job_success_times"
          placeholder="工作N次以上"
        />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询</el-button>
        <el-button @click="reset">重置</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { useFormData } from '@/utils/use-form-data';

  const emit = defineEmits(['search']);

  /** 表单数据 */
  const [form, resetFields] = useFormData({
    realname: '',
    tel: '',
    identifier: '',
    job_success_times: '',
    sons: 0,
    parent_id: 0,
    blacklist: 99999999,
    active: 1,
    startDate: '',
    endDate: '',
    site_id: '',
    tenant_id: 0
  });

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };

  /**  重置 */
  const reset = () => {
    resetFields();
    search();
  };
</script>
